﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using qiupeng.Public;
using System.IO;

public partial class HumanManage_Staff_list_update : Base
{
    Db List = new Db();
    BindDrowDownList list = new BindDrowDownList();
    public string fjkey, XinagPian;
    public string showjg;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.fjkey = this.Session["FjKey"].ToString();
        if (!this.Page.IsPostBack)
        {
            this.BindAttribute();
        }
        if (!base.IsPostBack)
        {
            string sQL = "select * from qp_hr_SysData where  type='1'";
            this.list.Bind_DropDownList_nothing(this.WenHua, sQL, "name", "name");
            string str2 = "select * from qp_hr_SysData where  type='27'";
            this.list.Bind_DropDownList_nothing(this.RenCaiFenLei, str2, "name", "name");
            string str3 = "select * from qp_hr_SysData where  type='16'";
            this.list.Bind_DropDownList_nothing(this.RenCaiDengJi, str3, "name", "name");
            string str4 = "select * from qp_hr_SysData where  type='47'";
            this.list.Bind_DropDownList_nothing(this.YgGongZ, str4, "name", "name");
            string str5 = "select * from qp_hr_SysData where  type='57'";
            this.list.Bind_DropDownList_nothing(this.drpzhiweileibie, str5, "name", "name");
            string str6 = "select * from qp_hr_Staff where id='" + this.List.GetFormatStr(base.Request.QueryString["id"]) + "'";
            OleDbDataReader reader = this.List.GetList(str6);
            if (reader.Read())
            {
                this.ChuSheng.Text = DateTime.Parse(reader["ChuSheng"].ToString()).ToShortDateString();
                this.Number.Text = reader["Number"].ToString();
                this.GongHao.Text = reader["GongHao"].ToString();
                this.XingMing.Text = reader["XingMing"].ToString();
                this.XingBie.SelectedValue = reader["XingBie"].ToString();
                this.HunYin.SelectedValue = reader["HunYin"].ToString();
                this.JiGuan.Text = reader["JiGuan"].ToString();
                this.MinZhu.Text = reader["MinZhu"].ToString();
                this.JianKan.Text = reader["JianKan"].ToString();
                this.ZhengZhi.Text = reader["ZhengZhi"].ToString();
                this.ShenFen.Text = reader["ShenFen"].ToString();
                this.GongZuoShiJian.Text = reader["GongZuoShiJian"].ToString();
                this.GongZuoNianXian.Text = reader["GongZuoNianXian"].ToString();
                this.WenHua.SelectedValue = reader["WenHua"].ToString();
                this.BiYe.Text = reader["BiYe"].ToString();
                this.ZhuanYe.Text = reader["ZhuanYe"].ToString();
                this.BiYeShiJian.Text = reader["BiYeShiJian"].ToString();
                this.SuoXueWaiYu.Text = reader["SuoXueWaiYu"].ToString();
                this.WaiYu.Text = reader["WaiYu"].ToString();
                this.ZhangWo.Text = reader["ZhangWo"].ToString();
                this.JiSuanJiDj.Text = reader["JiSuanJiDj"].ToString();
                this.RenCaiFenLei.SelectedValue = reader["RenCaiFenLei"].ToString();
                this.RenCaiDengJi.SelectedValue = reader["RenCaiDengJi"].ToString();
                this.SuoHuoZhenShu.Text = reader["SuoHuoZhenShu"].ToString();
                this.JiaoYuJIanLi.Text = reader["JiaoYuJIanLi"].ToString();
                this.TeChang.Text = reader["TeChang"].ToString();
                this.AiHao.Text = reader["AiHao"].ToString();
                this.Email.Text = reader["Email"].ToString();
                this.LianXiDiZhi.Text = reader["LianXiDiZhi"].ToString();
                this.LianXIDianHua.Text = reader["LianXIDianHua"].ToString();
                this.YouBian.Text = reader["YouBian"].ToString();
                this.ShenGao.Text = reader["ShenGao"].ToString();
                this.TiZhong.Text = reader["TiZhong"].ToString();
                this.XueXing.Text = reader["XueXing"].ToString();
                this.GongZuoYQ.Text = reader["GongZuoYQ"].ToString();
                this.DaoGangRQ.Text = DateTime.Parse(reader["DaoGangRQ"].ToString()).ToShortDateString();
                this.YinPinBMId.Text = reader["YinPinBMId"].ToString();
                this.YinPinBM.Text = reader["YinPinBM"].ToString();
                this.YinPinZW.Text = reader["YinPinZW"].ToString();
                this.YgGongZ.SelectedValue = reader["YgGongZ"].ToString();
                this.BeiZhu.Text = reader["BeiZhu"].ToString();
                this.Zhiwu.Text = reader["Zhiwu"].ToString();
                this.ZhiCheng.Text = reader["ZhiCheng"].ToString();
                this.JbGongZ.Text = reader["JbGongZ"].ToString();
                this.YgZhuangTai.SelectedValue = reader["YgZhuangTai"].ToString();
                this.BeiZhu.Text = reader["BeiZhu"].ToString();
                this.XinagPian = reader["XiangPian"].ToString();
                this.Shgx.Text = reader["Shgx"].ToString();
                this.Gzjl.Text = reader["Gzjl"].ToString();
                this.Xxjl.Text = reader["Xxjl"].ToString();
                this.KaiHu.Text = reader["KaiHu"].ToString();
                this.ZhangHao.Text = reader["ZhangHao"].ToString();
                this.drpzhiweileibie.SelectedValue = reader["zhiweileibie"].ToString();
            }
            reader.Close();
        }
        string sql = "select  * from qp_hr_SysFieldDIYAdd where keyfile='" + this.Number.Text + "'  order by PaiXun asc";
        OleDbDataReader list = this.List.GetList(sql);
        this.showjg = null;
        if (list.Read())
        {
            string str8 = "select  * from qp_hr_SysFieldDIYAdd where keyfile='" + this.Number.Text + "'  order by PaiXun asc";
            OleDbDataReader reader3 = this.List.GetList(str8);
            int num = 0;
            this.showjg = this.showjg + "<tr> <td align=center bgcolor=#efefef class=cpx12hei colspan=4 height=26 width=33%><div align=center><strong>用户自定义字段</strong></div> </td> </tr>";
            while (reader3.Read())
            {
                object showjg = this.showjg;
                this.showjg = string.Concat(new object[] { showjg, " <tr> <td align=right bgcolor=#cccccc class=cpx12hei height=17 nowrap=nowrap width=17%>", reader3["Name"], "：</td> <td bgcolor=#efefef class=cpx12hei height=17 width=33% colspan=3>", reader3["s_str"], reader3["ivalue"], reader3["l_str"], "</td></tr>" });
                num++;
                if (num == 1)
                {
                    num = 0;
                }
            }
            reader3.Close();
        }
        list.Close();
        this.BindDroList();

    }

    public void BindAttribute()
    {
        this.WenHua.Attributes.Add("readonly", "readonly");
        this.YinPinBM.Attributes.Add("readonly", "readonly");
        this.DaoGangRQ.Attributes.Add("readonly", "readonly");
        this.Button1.Attributes["onclick"] = "javascript:return chknull();";
        this.Button4.Attributes["onclick"] = "javascript:return checkForm();";
        this.Button3.Attributes["onclick"] = "javascript:return delfj();";

    }



    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = base.Server.MapPath("StaffPhoto/");
        string str2 = string.Empty;
        string str3 = string.Empty;

        string str14 = "select  * from qp_hr_Staff where gonghao='" + this.GongHao.Text + "' and KeyFile!='" + this.Number.Text + "'";
        OleDbDataReader reader4 = this.List.GetList(str14);
        while (reader4.Read())
        {
            this.Page.RegisterStartupScript("","<script language='javascript'>alert('工号重复！');</script>");
            return;
        }
        reader4.Close();

        if (this.File1.PostedFile.ContentLength != 0)
        {
            string extension = Path.GetExtension(Path.GetFileName(this.File1.PostedFile.FileName));
            string str6 = this.Session["FjKey"].ToString();
            if (!this.List.StrIFInStr(extension, str6))
            {
                base.Response.Write("<script language=javascript>alert('上传照片错误！允许上传格式为" + this.Session["FjKey"].ToString() + "');</script>");
                return;
            }
            Random random = new Random();
            string str7 = random.Next(0x2710).ToString();
            str3 = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + str7;
            this.File1.PostedFile.SaveAs(str + str3 + extension);
            str2 = str3 + extension;
            string str8 = "Update qp_hr_Staff   Set  KaiHu='" + this.List.GetFormatStr(this.KaiHu.Text) + "',ZhangHao='" + this.List.GetFormatStr(this.ZhangHao.Text) + "',Shgx='" + this.List.GetFormatStr(this.Shgx.Text) + "',Gzjl='" + this.List.GetFormatStr(this.Gzjl.Text) + "',Xxjl='" + this.List.GetFormatStr(this.Xxjl.Text) + "',XingMing='" + this.List.GetFormatStr(this.XingMing.Text) + "',XingBie='" + this.List.GetFormatStr(this.XingBie.SelectedValue) + "',HunYin='" + this.List.GetFormatStr(this.HunYin.SelectedValue) + "',ChuSheng='" + this.List.GetFormatStr(this.ChuSheng.Text) + "',JiGuan='" + this.List.GetFormatStr(this.JiGuan.Text) + "',MinZhu='" + this.List.GetFormatStr(this.MinZhu.Text) + "',JianKan='" + this.List.GetFormatStr(this.JianKan.Text) + "',ZhengZhi='" + this.List.GetFormatStr(this.ZhengZhi.Text) + "',ShenFen='" + this.List.GetFormatStr(this.ShenFen.Text) + "',GongZuoShiJian='" + this.List.GetFormatStr(this.GongZuoShiJian.Text) + "',GongZuoNianXian='" + this.List.GetFormatStr(this.GongZuoNianXian.Text) + "',WenHua='" + this.List.GetFormatStr(this.WenHua.SelectedValue) + "',BiYe='" + this.List.GetFormatStr(this.BiYe.Text) + "',ZhuanYe='" + this.List.GetFormatStr(this.ZhuanYe.Text) + "',BiYeShiJian='" + this.List.GetFormatStr(this.BiYeShiJian.Text) + "',SuoXueWaiYu='" + this.List.GetFormatStr(this.SuoXueWaiYu.Text) + "',WaiYu='" + this.List.GetFormatStr(this.WaiYu.Text) + "',ZhangWo='" + this.List.GetFormatStr(this.ZhangWo.Text) + "',JiSuanJiDj='" + this.List.GetFormatStr(this.JiSuanJiDj.Text) + "',RenCaiFenLei='" + this.List.GetFormatStr(this.RenCaiFenLei.SelectedValue) + "',RenCaiDengJi='" + this.List.GetFormatStr(this.RenCaiDengJi.SelectedValue) + "',SuoHuoZhenShu='" + this.List.GetFormatStr(this.SuoHuoZhenShu.Text) + "',JiaoYuJIanLi='" + this.List.GetFormatStr(this.JiaoYuJIanLi.Text) + "',TeChang='" + this.List.GetFormatStr(this.TeChang.Text) + "',AiHao='" + this.List.GetFormatStr(this.AiHao.Text) + "',Email='" + this.List.GetFormatStr(this.Email.Text) + "',LianXiDiZhi='" + this.List.GetFormatStr(this.LianXiDiZhi.Text) + "',LianXIDianHua='" + this.List.GetFormatStr(this.LianXIDianHua.Text) + "',YouBian='" + this.List.GetFormatStr(this.YouBian.Text) + "',ShenGao='" + this.List.GetFormatStr(this.ShenGao.Text) + "',TiZhong='" + this.List.GetFormatStr(this.TiZhong.Text) + "',XueXing='" + this.List.GetFormatStr(this.XueXing.Text) + "',GongZuoYQ='" + this.List.GetFormatStr(this.GongZuoYQ.Text) + "',DaoGangRQ='" + this.List.GetFormatStr(this.DaoGangRQ.Text) + "',YinPinBMId='" + this.List.GetFormatStr(this.YinPinBMId.Text) + "',YinPinBM='" + this.List.GetFormatStr(this.YinPinBM.Text) + "',YinPinZW='" + this.List.GetFormatStr(this.YinPinZW.Text) + "',YgGongZ='" + this.List.GetFormatStr(this.YgGongZ.SelectedValue) + "',Zhiwu='" + this.List.GetFormatStr(this.Zhiwu.Text) + "',ZhiCheng='" + this.List.GetFormatStr(this.ZhiCheng.Text) + "',JbGongZ='" + this.List.GetFormatStr(this.JbGongZ.Text) + "', XiangPian='" + str2 + "',BeiZhu='" + this.List.GetFormatStr(this.BeiZhu.Text) + "',zhiweileibie='" + this.drpzhiweileibie.SelectedValue + "' where  KeyFile='" + this.Number.Text + "'";
            this.List.ExeSql(str8);
        }
        else
        {
            string str9 = "Update qp_hr_Staff   Set  KaiHu='" + this.List.GetFormatStr(this.KaiHu.Text) + "',ZhangHao='" + this.List.GetFormatStr(this.ZhangHao.Text) + "',Xxjl='" + this.List.GetFormatStr(this.Xxjl.Text) + "',XingMing='" + this.List.GetFormatStr(this.XingMing.Text) + "',XingBie='" + this.List.GetFormatStr(this.XingBie.SelectedValue) + "',HunYin='" + this.List.GetFormatStr(this.HunYin.SelectedValue) + "',ChuSheng='" + this.List.GetFormatStr(this.ChuSheng.Text) + "',JiGuan='" + this.List.GetFormatStr(this.JiGuan.Text) + "',MinZhu='" + this.List.GetFormatStr(this.MinZhu.Text) + "',JianKan='" + this.List.GetFormatStr(this.JianKan.Text) + "',ZhengZhi='" + this.List.GetFormatStr(this.ZhengZhi.Text) + "',ShenFen='" + this.List.GetFormatStr(this.ShenFen.Text) + "',GongZuoShiJian='" + this.List.GetFormatStr(this.GongZuoShiJian.Text) + "',GongZuoNianXian='" + this.List.GetFormatStr(this.GongZuoNianXian.Text) + "',WenHua='" + this.List.GetFormatStr(this.WenHua.SelectedValue) + "',BiYe='" + this.List.GetFormatStr(this.BiYe.Text) + "',ZhuanYe='" + this.List.GetFormatStr(this.ZhuanYe.Text) + "',BiYeShiJian='" + this.List.GetFormatStr(this.BiYeShiJian.Text) + "',SuoXueWaiYu='" + this.List.GetFormatStr(this.SuoXueWaiYu.Text) + "',WaiYu='" + this.List.GetFormatStr(this.WaiYu.Text) + "',ZhangWo='" + this.List.GetFormatStr(this.ZhangWo.Text) + "',JiSuanJiDj='" + this.List.GetFormatStr(this.JiSuanJiDj.Text) + "',RenCaiFenLei='" + this.List.GetFormatStr(this.RenCaiFenLei.SelectedValue) + "',RenCaiDengJi='" + this.List.GetFormatStr(this.RenCaiDengJi.SelectedValue) + "',SuoHuoZhenShu='" + this.List.GetFormatStr(this.SuoHuoZhenShu.Text) + "',JiaoYuJIanLi='" + this.List.GetFormatStr(this.JiaoYuJIanLi.Text) + "',TeChang='" + this.List.GetFormatStr(this.TeChang.Text) + "',AiHao='" + this.List.GetFormatStr(this.AiHao.Text) + "',Email='" + this.List.GetFormatStr(this.Email.Text) + "',LianXiDiZhi='" + this.List.GetFormatStr(this.LianXiDiZhi.Text) + "',LianXIDianHua='" + this.List.GetFormatStr(this.LianXIDianHua.Text) + "',YouBian='" + this.List.GetFormatStr(this.YouBian.Text) + "',ShenGao='" + this.List.GetFormatStr(this.ShenGao.Text) + "',TiZhong='" + this.List.GetFormatStr(this.TiZhong.Text) + "',XueXing='" + this.List.GetFormatStr(this.XueXing.Text) + "',GongZuoYQ='" + this.List.GetFormatStr(this.GongZuoYQ.Text) + "',DaoGangRQ='" + this.List.GetFormatStr(this.DaoGangRQ.Text) + "',YinPinBMId='" + this.List.GetFormatStr(this.YinPinBMId.Text) + "',YinPinBM='" + this.List.GetFormatStr(this.YinPinBM.Text) + "',YinPinZW='" + this.List.GetFormatStr(this.YinPinZW.Text) + "',YgGongZ='" + this.List.GetFormatStr(this.YgGongZ.SelectedValue) + "',Zhiwu='" + this.List.GetFormatStr(this.Zhiwu.Text) + "',ZhiCheng='" + this.List.GetFormatStr(this.ZhiCheng.Text) + "',JbGongZ='" + this.List.GetFormatStr(this.JbGongZ.Text) + "',gonghao='" + this.GongHao.Text + "', BeiZhu='" + this.List.GetFormatStr(this.BeiZhu.Text) + "',zhiweileibie='" + this.drpzhiweileibie.SelectedValue + "' where  KeyFile='" + this.Number.Text + "'";
            this.List.ExeSql(str9);
        }
        string sql = "update qp_hr_username set StaffNumer='" + this.List.GetFormatStr(this.GongHao.Text) + "',XingMing='" + this.List.GetFormatStr(this.XingMing.Text) + "',XingBie='" + this.List.GetFormatStr(this.XingBie.SelectedValue) + "',ShenFen='" + this.List.GetFormatStr(this.ShenFen.Text) + "',BuMenId='" + this.List.GetFormatStr(this.YinPinBMId.Text) + "',BuMen='" + this.List.GetFormatStr(this.YinPinBM.Text) + "',GangWei='" + this.List.GetFormatStr(this.YinPinZW.Text) + "',ZhiWu='" + this.List.GetFormatStr(this.Zhiwu.Text) + "' where StaffId='" + this.List.GetFormatStr(base.Request.QueryString["id"]) + "'";
        this.List.ExeSql(sql);
        string str11 = "select  * from qp_hr_SysFieldDIYAdd where keyfile='" + this.Number.Text + "'  order by PaiXun asc";
        OleDbDataReader list = this.List.GetList(str11);
        if (list.Read())
        {
            string str12 = "select  * from qp_hr_SysFieldDIYAdd where keyfile='" + this.Number.Text + "'  order by PaiXun asc";
            OleDbDataReader reader2 = this.List.GetList(str12);
            while (reader2.Read())
            {
                string Sql_update = "Update qp_hr_SysFieldDIYAdd  Set ivalue='" + Request.Form["" + reader2["Number"] + ""] + "'  where Number='" + reader2["Number"] + "' and  keyfile='" + Number.Text + "' ";
                List.ExeSql(Sql_update);
            }
            reader2.Close();
        }
        list.Close();
        this.List.InsertLog("修改人事管理[" + this.XingMing.Text + "]", "人事管理");
        base.Response.Write("<script language=javascript>alert('提交成功！');window.opener.location.reload();window.close();</script>");


    }

    protected void Button4_Click(object sender, EventArgs e)
    {
        string str = base.Server.MapPath("Staff/");
        string str2 = string.Empty;
        string str3 = string.Empty;
        if (this.uploadFile.PostedFile.ContentLength != 0)
        {
            string fileName = Path.GetFileName(this.uploadFile.PostedFile.FileName);
            string extension = Path.GetExtension(fileName);
            string str6 = this.Session["FjKey"].ToString();
            if (!this.List.StrIFInStr(extension, str6))
            {
                base.Response.Write("<script language=javascript>alert('上传文件错误！允许上传格式为" + this.Session["FjKey"].ToString() + "');</script>");
            }
            else
            {
                Random random = new Random();
                string str7 = random.Next(0x2710).ToString();
                str3 = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + str7;
                this.uploadFile.PostedFile.SaveAs(str + str3 + extension);
                str2 = str3 + extension;
                string sql = "insert into qp_hr_fileupload   (Name,NewName,KeyField) values ('" + fileName + "','HumanManage/Staff/" + str2 + "','" + this.Number.Text + "')";
                this.List.ExeSql(sql);
                this.List.InsertLog("上传附件[" + fileName + "]", "人事管理");
                this.BindDroList();
            }
        }

    }

    public void BindDroList()
    {
        string sQL = "select * from qp_hr_fileupload where KeyField='" + this.Number.Text + "'";
        this.list.Bind_DropDownList_nothing(this.fjlb, sQL, "NewName", "Name");

    }
}
